<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>双伪元素法</title>
    <!-- 同时解决父子元素外边距重叠和 清除浮动问题(一个简便写法，因为浮动带来的高度塌陷和垂直外边距的问题是不会同时出现的)-->
</head>
<style>
    * {
        margin: 0;
        padding: 0;
    }
    
    div {
        border: 5px solid red;
    }
    
    p {
        float: left;
        width: 100px;
        height: 100px;
        background-color: blue;
    }
    
    .clearFix::before,
     ::after {
        content: '';
        display: table;
        /*这里我觉得display:block; + overflow:hidden也可以的*/
        clear: both;
        height: 0;
        visibility: hidden;
    }
</style>

<body>
    <div class="box clearFix">
        <p></p>
    </div>
</body>

</html>